package com.mywangjie.delete.controller;

import com.mywangjie.delete.utils.DelFile;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

/**
 * @author wangjie
 * @version V1.0
 * @title: ToolContoller
 * @package: com.example.delete.controller
 * @description: TODO
 * @date 2021/10/21 6:26 下午
 **/
@RestController
public class ToolController {

    @ApiOperation(value = "删除文件", notes = "删除文件")
    @GetMapping({"/delFile"})
    public String delFile(@ApiParam(name = "path", value = "目录", required = true, defaultValue = "/Users/wangjie/Work/工作信息资料", example = "/Users/wangjie/Work/工作信息资料") @RequestParam("path") String path,
                          @ApiParam(name = "suffix", value = "要删除的文件夹名、文件名、文件后缀", required = true, defaultValue = "target", example = "target") @RequestParam("suffix") String suffix) {
        DelFile.scanAllFile(new File(path, suffix));
        return "delete success!";
    }
}
